<?php
/**
 *授权获取用户信息。包括头像、昵称
* http://lorealyichang.6edigital.cn/index.php?type=xxx&openid=xxx&nickname=xxx&headimgurl=xxx
 */
error_reporting(E_ALL & ~E_NOTICE);
include './oauth2.php';
$forward_type = $_GET['type'];
$code=$_GET['code'];//code 微信接口参数(必须)
$state=$_GET['state'];//state微信接口参数(不需传参则不用)；若传参可考虑规则： 'act'.'arg1'.'add'.'arg2'
$APPID='wx9c23eb0a5329ce6d';
$SECRET='fe01663819b38717e1106ae02e75d655';
$REDIRECT_URL='http://ethicsday.6edigital.cn/oauth_interface.php';//当前页面地址
$oauth2=new oauth2();
$oauth2->init($APPID, $SECRET,$REDIRECT_URL);
if(empty($code)){		
	$oauth2->get_code_by_authorize($state);//获取code，会重定向到当前页。若需传参，使用$state变量传参。
}
$data=$oauth2->get_userinfo_by_authorize();

// echo '</br>nickname: '.$data['nickname'];
// echo '</br>headimgurl: '.$data['headimgurl'];

 // $return_value = json_encode($data,JSON_UNESCAPED_UNICODE);
 // echo $return_value;
 $forward_url = "Location:http://ethicsday.6edigital.cn/oauth_forward.php?type=".$forward_type."&openid=".$open_id."&nickname=".$nick_name."&headimgurl=".$head;
 header($forward_url);
 exit;
?>
